<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2545：[Ctsc2002]丹奇方块</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2002]丹奇方块</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2002]丹奇方块</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Ctsc2002]丹奇方块                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p><span style="font-size: medium">佳佳最近被一个叫做&ldquo;丹奇方块&rdquo;的游戏吸引住了，但是却因为游戏太难而迟迟无法通关。游戏在一个没有边界的棋盘上进行，中心(0,0)处有一块黑色的障碍物，不远处坐标值为奇数的N个不同的格子中各有一个灰色方块。游戏的任务是把所有灰色方块全部粘起来组成一个给定的形状，如图一所示。该形状可以出现在棋盘上的任何位置，但不能旋转或者对称。图二描述了一个合法的初始状态，其中在坐标(-1,-1),(1,-1),(1,1)处各有一个灰色方块。</span></p>
<p><span style="font-size: medium"><img alt="" src="../file/2545_0.jpg" /></span></p>
<p><span style="font-size: medium">这个游戏看起来简单，但方块数目多，目标形状又很复杂的时候游戏者往往需要很多步才能完成。佳佳希望找到一个不超过2000步的解决方案，你能帮帮他吗？</span></p></p><hr/><h3>输入格式</h3><p><p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">&nbsp;&nbsp;&nbsp; 第一行包含一个整数</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">N</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">（</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">3&lt;=N&lt;=20</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">，即方块个数。<span lang="EN-US"><o:p></o:p></span></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><font face="宋体"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</span></font><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">2</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">行包含</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">N</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个整数对</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">x<sub>i</sub>, y<sub>i</sub>, (-9&lt;=x<sub>i</sub>,y<sub>i</sub>&lt;=9,<i style="mso-bidi-font-style: normal"> </i>x<sub>i</sub>,y<sub>i</sub></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">为奇数</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">) </span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">其中第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个整数对代表第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个方块的初始位置。位置按照从上到下（即</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">x</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">递增）从左到右（即</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">y</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">递增）的顺序排列。</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">3</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">行包含</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">N</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个整数对</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">Px<sub>i</sub>, Py<sub>i</sub>(1&lt;=Px<sub>i</sub>,Py<sub>i</sub>&lt;=N)</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">，代表目标形状中各小方块的相对位置。目标方块保证是一个连在一起的整体，且数据总是有解的。</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></p>
<p></p></p><hr/><h3>输出格式</h3><p><p><span style="font-size: 12pt; font-family: 宋体; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">第一行为需要的步数</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体">S</span></p></p><hr/><h3>样例输入</h3><pre>3
-1  -1    1   -1    1    1
</pre><hr/><h3>样例输出</h3><pre>7</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>鸣谢刘汝佳先生授权使用</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2545" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2545" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>